<?php
/**
*
+------------------------------------+
| BitLF [ FAST DEVELOP KIT ]         |
+------------------------------------+
| 2010-2016 (c)                      |
+------------------------------------+
| Author: amamatthew                 |
+------------------------------------+
* 日    期：2017-08-06
* 版    本：1.0.0
* 功能说明：时间戳字符串工具类。
**/
namespace app\ux;

class UtilId {

	//基于(秒)返回唯一ID
	public function _YmdHis(){
		
		echo(date("YmdHis"));
	}
	//基于微秒返回唯一ID
	public function _uniqid(){
		
		return uniqid();
	}
	//定长字符串自动补全
	public function _fixleng($str,$length,$pad=null){
		
		if(null==$pad){
			sprintf('%0'.$length.'s', $str);
		}else{
			sprintf("%'".$pad.$length.'s', $str);
		}
	}
	//基于1e-3毫秒时间戳
	public function _millisec(){
		
		$time = explode ( " ", microtime () );
		$time = $time [1] . ($time [0] * 1000);
		$time2 = explode ( ".", $time );
		return $time2 [0];
	}	
	//基于1e-6微秒时间戳
	public function _microsec(){
		
		$time = explode ( " ", microtime () );
		$time = $time [1] . ($time [0] * 1000000);
		$time2 = explode ( ".", $time );
		return $time2 [0];
	}
}